<?php
require_once 'core/conn.php';
require_once 'core/sqlsearch.php';
require_once 'core/function.php';
header('content-type:text/html;charset=utf-8');
if (isset($_SESSION['uid'])) {
    $panduan = sql_uid_login($_SESSION['uid']);
    if ($panduan[0]) {
        echo "<script>alert('由于您的操作异常已被管理员踢下线，封锁至" . $panduan[1] . "')</script>";
        session_unset();
        session_destroy();
    }
}

if (!$_POST) {
    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
        <meta name="viewport"
              content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="css/style.css"/>
        <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
        <script src="js/ajaxpost.js"></script>
        <script src="js/app.js"></script>
        <title>论坛0<?php
            if (isset($_SESSION['uid'])) {
                $setuser_all = sql_search_uid_all($_SESSION['uid']);
            }
            if ($_SERVER['PHP_SELF'] == '/bbs_0/signin.php') {
                echo '-用户注册';
            } elseif ($_SERVER['PHP_SELF'] == '/bbs_0/login.php') {
                echo '-用户登录';
            } elseif ($_SERVER['PHP_SELF'] == '/bbs_0/admin.php') {
                echo '-管理面板';
                echo '-管理员' . $setuser_all['user_username'];
            } elseif (isset($_SESSION['uid'])) {
                echo '-欢迎您，' . $setuser_all['user_username'];
            } elseif ($_SERVER['PHP_SELF'] == '/bbs_0/post.php') {
                echo '-正在为您传输数据';
            }
            ?></title>
    </head>
    <body>
    <a href="forum.php">论坛首页</a>

    <?php
    $url = $_SERVER['REQUEST_URI'];
    if (!isset($_SESSION['uid'])) {
        echo '<a href="login.php?back=\'' . base64_encode($url) . '\'">请登录</a>';
    } else {
        if ($_SERVER['PHP_SELF'] != '/bbs_0/post.php') {
            if ($_SERVER['PHP_SELF'] == '/bbs_0/admin.php') {
                echo '管理员，' . '<a href="home.php?mod=space&uid=' . $_SESSION['uid'] . '">' . $setuser_all['user_username'] . '</a>';
            } elseif ($_SESSION['rank'] == 10) {
                echo '管理员，' . '<a href="home.php?mod=space&uid=' . $_SESSION['uid'] . '">' . $setuser_all['user_username'] . '</a>';
            } else {
                echo '欢迎您，' . '<a href="home.php?mod=space&uid=' . $_SESSION['uid'] . '">' . $setuser_all['user_username'] . '</a>';
            }
            echo '<input type="button" onclick="var i = confirm(\'确认登出？\');if (i){ ajaxpost_logout();}" value="登出"/>';
            if ($_SESSION['rank'] == 10) {
                echo '&nbsp;&nbsp;';
                echo '<a href="admin.php">管理面板</a>';
            } elseif ($_SESSION['rank'] > 4) {
                echo '&nbsp;&nbsp;';
                $rank = $_SESSION['rank'];
                $list = mysqli_fetch_array(mysqli_query($conn, "SELECT forum_id FROM bbs0_forums WHERE auth_edit=$rank"));
                echo '<a href="admin.php?type=area&id=1&forumid=' . $list['forum_id'] . '">编辑管理面板</a>';
            }
        }
    }
    if (isset($_GET['content']))
        $searchContent = trim($_GET['content']);
    else
        $searchContent = "";
    if (isset($_SESSION['uid'])) {
        reply_notify($_SESSION['uid']);
    }


    $color = isset($_SESSION['color']) ? $_SESSION['color'] : "#FFFFFF";
    $uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : 0;
    echo '<br />主题：';
    echo '<input  type="color" id="changeColor" onchange="ajaxpost_changeBgColor(' . $uid . ')" value="' . $color . '">';
    searchSubmit();
    locationhead();
    echo '<body style=" background: ' . $color . ';">';
}
?>